<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'modify.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    		<center>
    			<h1>用户修改</h1>
    			<form action="update" method="post" onsubmit="return aa();">
    				<input type="hidden" value="${info.userId }" name="userId" />
    				<input type="hidden" value="${info.password }" name="oldpw" />
	    			用户账号<input type="text" disabled="disabled" value="${info.userAccount }"><br/>
	    			邮箱	<input type="text" name="email" value="${info.userAccount}"><br/>
	    			原密码<input type="password" name="oldPassword" ><br/>
	    			新密码<input type="password" name="password" ><br/>
	    			所属部门 
	    					<select name="deptId">
	    						<option value="">请选择</option>
	    						<c:forEach items="${allDepts}" var="allDepts">
	    						<option <c:if test="${allDepts.deptId==info.deptId }">selected</c:if> value="${allDepts.deptId }">${allDepts.deptName }</option>
	    						</c:forEach>
	    					</select>
	    					<br/>
	    			<input type="submit" value="保存"/>
	    			<a href="list"><input type="button" value="返回"/></a>
    			</form>
    		</center>
    		<script type="text/javascript" src="js/jquery-1.12.4.js"></script>
    		<script type="text/javascript">
    			function aa(){
    				var oldPassword = $("[name=oldPassword]").val();
    				var password = $("[name=password]").val();
    				var email = $("[email=password]").val();
    				var deptId = $("[name=deptId]").val();
    				var oldpw = $("[name=oldpw]").val();
    			
    				if(oldPassword!=oldpw){
    					alert("原密码不一致");
    					return false;
    				}
    					
    				if(password.length<6){
    					alert("密码不能小于6位");
    					return false;
    				}
    				
    				if(oldPassword==password){
    					alert("原密码不新密码不能一致");
    					return false;
    				}
    				if(deptId==""){
   						alert("请选择部门");
   						return false;
    				}
    				return true;
    			}
    		</script>
  </body>
</html>
